package web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
//@RequestMapping("index")
public class IndexController {
    @RequestMapping("index")
    public ModelAndView index(String target){
        //通过ModelAndView 的实例可以向index.jsp传值
        //有相同功能的还包括Map、Model
        ModelAndView view = new ModelAndView("index");

        if(StringUtils.isEmpty(target)){
            target = "welcome";
        }
        view.addObject("t",target+".jsp");
        return view;
    }
}
